home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 2.4 KB | 95 lines | [TEXT/ToyS] |
- property kasMaxDepth : 16 -- Maximum folders to follow down
-
- property kasOwnerID : "R*ch" -- Owner to use
- property kasTypes : {"TEXT"} -- Files to adjust
-
- property sasInfoLoc : {-1, -1}
-
- global gasInfo
-
-
- on run
- open {choose folder with prompt "Choose a folder with text files to convert…"}
- end run
-
-
- on open fsObjs
- set gasInfo to display info titled ¬
- "Changing Owner" message ¬
- "Scanning…" located at sasInfoLoc
-
- set ftype to ""
- if (option key down of (input state)) then ¬
- set ftype to GetType()
-
- repeat with fsObj in fsObjs
- SetFSOwner(fsObj, kasOwnerID, ftype, kasMaxDepth)
- end repeat
-
- -- Close info window
- set newLoc to screen location of (display info gasInfo with disposal)
-
- -- Save window location
- if (newLoc is not sasInfoLoc) then set sasInfoLoc to newLoc
- end open
-
-
- on SetFSOwner(fsObj, ownerID, ftype, depth)
- set info to basic info for fsObj
-
- if (the catalog kind of info is a folder) then
- set daddy to (fsObj as string)
-
- -- Do text files
- if (ftype is "") then
- set itemList to the entries in fsObj whose types are in kasTypes
- else
- set itemList to the entries in fsObj
- end if
-
- repeat with fname in itemList
- SetFSOwner((daddy & fname) as alias, ownerID, ftype, depth)
- end repeat
-
- -- Do further folders
- set depth to depth - 1
- if (depth > 0) then
- set itemList to the entries in fsObj whose types are in {"fold"}
-
- repeat with fname in itemList
- SetFSOwner((daddy & fname) as alias, ownerID, ftype, depth)
- end repeat
- end if
- else if ((system type of info) is in kasTypes) or (ftype is not "") then
- SetFileOwner(fsObj, ownerID, ftype)
- else if ((system type of info) is "APPL") then
- set the icon of (path to me) to (the icon for fsObj)
- set kasOwnerID to (system creator of info)
- collate (path to me) renaming it to ("Owned by " & (catalog name of info))
- end if
-
- end SetFSOwner
-
-
- on SetFileOwner(fsObj, newOwner, newType)
- set x to fsObj as string
- if ((length of x) > 255) then set x to "…" & (the text from character -254 to -1 of x)
- display info gasInfo message x
- set info to basic info for fsObj
- set system creator of info to newOwner
- if (newType is not "") then set system type of info to newType
- set the catalog info of fsObj to info
- end SetFileOwner
-
-
- on GetType()
- display dialog ("Change the type of the dropped files to:") ¬
- default answer "TEXT" default button 2
- set ftype to text returned of the result
- if length of ftype is not 4 then
- beep
- set ftype to ""
- end if
- return ftype
- end GetType
-